package com.example.demo.service

import com.example.demo.JsonUtil
import com.example.demo.SQLUtil
import com.example.demo.bean.BaseResponse
import com.example.demo.bean.SUCCESS
import javax.servlet.annotation.WebServlet
import javax.servlet.http.HttpServlet
import javax.servlet.http.HttpServletRequest
import javax.servlet.http.HttpServletResponse

@WebServlet(name = "all_orders", value = ["/all_orders"])
class AllOrder : HttpServlet() {
    override fun doGet(req: HttpServletRequest, resp: HttpServletResponse) {
        val allOrders = SQLUtil.getTheAllOrderInfo()
        resp.contentType = "text/json;charset=UTF-8"
        resp.writer.println(JsonUtil.toJson(BaseResponse(code = SUCCESS, data = allOrders)))
    }
}